from flask import Flask,request,render_template,url_for,Response,Request

from shoot_util import shoot_command_path_dir,find_max_num

app=Flask(__name__)

# #相机推流
# @app.route('/console',methods=['POST','GET'])#
# def show_img():
#     return render_template('./console.html')

# @app.route('/commands',methods=['POST','GET'])#
# def get_command():
#     if request.method == 'POST':
#         file = request.files['file']
#         print("收到指令文件：", file.filename)
#         file.save(f'./{shoot_command_path_dir}/{file.filename}')
#         return file.filename
#     else:
#         return """
#             <html><body>
#             <h1>文件上传示例</h1>
#             <form action="/commands" enctype='multipart/form-data' method='POST'>
#                 <input type='file' name='file'>
#                 <input type='submit' value='上传'>
#             </form>
#             </body></html>
#         """



# from flask_socketio import SocketIO,send,emit

# app.config['SECRET_KEY'] = 'secret!'
# socketio = SocketIO(app)


# @socketio.on('connect', namespace='/test.py')
# def test_connect():
#     emit('my response', {'data': 'Connected'})
#
#
# @socketio.on('disconnect', namespace='/test.py')
# def test_disconnect():
#     print('Client disconnected')
#
# @socketio.on('my event')
# def handle_my_custom_event(json):
#     emit('my response', json)


if __name__=='__main__':
    #CORS(app, supports_credentials=True)

    app.run(debug=False,host='0.0.0.0',port=6666)#192.168.199.213
    #0.0.0.0 http://127.0.0.1:8888/video 192.168.199.213
    # SCAUNET http://172.20.31.75:8888/video  http://172.20.15.185:8888/video http://172.20.26.96:8888/show_img

    # socketio.run(app, host='0.0.0.0', debug=True,port=8888)